package com.heima.kafka.listener;

import org.springframework.kafka.annotation.KafkaListener;
import org.springframework.stereotype.Component;
import org.springframework.util.StringUtils;

@Component
public class HelloListener {

    @KafkaListener(topics = "itcast-topic")
    public void onMessage(String message){
        if(!StringUtils.isEmpty(message)){
            System.out.println(message);
        }
    }

//    @KafkaListener(topics = "itcast-topic")
//    public void onMessage(ConsumerRecord<String, String> record, Consumer<String,String> consumer){
//        if(!StringUtils.isEmpty(record)){
//            System.out.println(record.value());
//            System.out.println(record.offset());
//            //提交偏移量
//            consumer.commitSync();
//        }
//    }
}